<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li:nth-child(2n+1) {
            color: red;
        }

        li:nth-child(2n) {
            color: blue;
        }

        /* 第一个  first-child  == nth-child(1) */
        li:first-child {
            background-color: #ff0;
        }

        li:nth-child(2) {
            background-color: #ddc;
        }

        li:last-child {
            background-color: #0f0;
        }



        /* nth-child 是第一个孩子 */
        .box p:nth-child(3) {
            color: red;
        }
    </style>
</head>

<body>

    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>


    <div class="box">
        <p>1</p>
        <h2>h2</h2>
        <p>2</p>
    </div>

</body>

</html>